<!--检测任务具体信息-->
<template>
	<view>
		<view class="task-result">
			<view class="result-item">已测数:{{examedCount}}</view>
			<view class="result-item">未测数:{{notExamCount}}</view>
			<view class="result-item">泄漏:{{leakNum}}</view>
		</view>
		<view class="schedule-circle">
				<view class="progressBox">
								<ProgressCircle :percent="80" :size="500" progressColor="#4ADA88" id='a'>
									<view class="centerTxt">
										<view class="num">
										{{progress}}
										</view>
										
									</view>
								</ProgressCircle>
							</view>

		</view>
		<view class="config-content">
			<view class="detection-parameter" @click="goToCalibration">
				<view class="detection-icon"></view>
				<view class="button-text-one">校准</view>
				</view>
			<view class="meteorological-parameter" @click="goToMeteorological">	
				<view class="button-text-two">气象五参数</view>
				<view class="meteorological-icon"></view>
				</view>
		</view>
		<view class="start-button">
				<button type="primary" class="mini-btn" @tap="startTesting">开始检测</button>
		</view>	
	</view>

	
</template>

<script setup>
	import {ref} from "vue"
	import {
		    onLoad,
		  } from "@dcloudio/uni-app";
	import TestingBarChart from './testingBarChart.vue'
    import ProgressCircle from './progress-circle.vue'
	const examedCount =ref(0)
	const notExamCount =ref(0)
	const leakNum =ref(0)
	const progress = ref(0)
	const taskId = ref('')
	onLoad((option) => {
		if(option){
			//console.log("oooooo",option.info);
			examedCount.value = JSON.parse(option.info).examedCount;
			notExamCount.value = JSON.parse(option.info).notExamCount;
			leakNum.value = JSON.parse(option.info).leakNum;
			progress.value = JSON.parse(option.info).progress; 
			taskId.value = JSON.parse(option.info).taskId; 
			uni.setStorageSync('factoryId',JSON.parse(option.info).factoryId);
			uni.setStorageSync('year',JSON.parse(option.info).year);
			uni.setStorageSync('season',JSON.parse(option.info).season);
			//console.log("ttttt",taskId.value);
		}
	});
	const goToCalibration = () =>{
	   let 	calibrationManagementList = [{
			factoryId: uni.getStorageSync("factoryId"),
			taskId: "1",
			examUser: "安卓",
			gasType: "零气",
			standardValue: "0",
			correctType: "日常",
			warmMin: "3",
			flowMin: "2",
			deviceId: "30",
			firstValue: "1",
			secondValue: "1",
			thirdValue: "1",
			averageValue: "1",
			differenceValue: "1",
			isPass: 1,
			creatTime: "2024-03-25"
		},
		{
			factoryId: uni.getStorageSync("factoryId"),
			taskId: "2",
			examUser: "安卓",
			gasType: "10k",
			standardValue: "300",
			correctType: "日常",
			warmMin: "3",
			flowMin: "2",
			deviceId: "1",
			firstValue: "1",
			secondValue: "1",
			thirdValue: "1",
			averageValue: "1",
			differenceValue: "1",
			isPass: 1,
			creatTime: "2024-03-25"
		},
		{
			factoryId: uni.getStorageSync("factoryId"),
			taskId: "3",
			examUser: "安卓",
			gasType: "10k",
			standardValue: "200",//浓度
			correctType: "日常",
			warmMin: "3",
			flowMin: "2",
			deviceId: "1",
			firstValue: "1",
			secondValue: "1",
			thirdValue: "1",
			averageValue: "1",
			differenceValue: "1",
			isPass: 0,
			creatTime: "2024-03-25"
		},
		{
				factoryId: uni.getStorageSync("factoryId"),
				taskId: "4",
				examUser: "安卓",
				gasType: "零气",
				standardValue: "0",
				correctType: "漂移",
				warmMin: "3",
				flowMin: "2",
				deviceId: "30",
				firstValue: "1",
				secondValue: "1",
				thirdValue: "1",
				averageValue: "",
				differenceValue: "1",
				isPass: 1,
				creatTime: "2024-03-25"
			},
			{
				factoryId: uni.getStorageSync("factoryId"),
				taskId: "5",
				examUser: "安卓",
				gasType: "10k",
				standardValue: "300",
				correctType: "漂移",
				warmMin: "3",
				flowMin: "2",
				deviceId: "1",
				firstValue: "1",
				secondValue: "1",
				thirdValue: "1",
				averageValue: "1",
				differenceValue: "1",
				isPass: 0,
				creatTime: "2024-03-25"
			},
			{
				factoryId: uni.getStorageSync("factoryId"),
				taskId: "6",
				examUser: "安卓",
				gasType: "10k",
				standardValue: "300",
				correctType: "漂移",
				warmMin: "3",
				flowMin: "2",
				deviceId: "1",
				firstValue: "1",
				secondValue: "1",
				thirdValue: "1",
				averageValue: "1",
				differenceValue: "1",
				isPass: 1,
				creatTime: "2024-03-25"
			}
	];
	if(uni.getStorageSync("calibrationManagementList")){
	   console.log('vvfff',uni.getStorageSync("calibrationManagementList"));	
	} else {
		uni.setStorageSync("calibrationManagementList",calibrationManagementList);
	}
		
		uni.navigateTo({
			url: '/pages/testing/calibrationManagement?taskId='+ taskId.value
					});
	}
	const goToMeteorological = () =>{
		uni.navigateTo({
			url: '/pages/testing/meteorologicalParametersList?taskId='+ taskId.value
					});
	}
	const startTesting =() =>{
		//console.log("ttttt444",taskId.value);
		//进行检测前先取缓存里的数据判断是否全部通过，
		console.log("aaaaaa",taskId.value);
		console.log("1111111",uni.getStorageSync('calibrationManagementList'));
		console.log("2222222",uni.getStorageSync('meteorologicalParameters'));
		let calibrationList = uni.getStorageSync('calibrationManagementList');
		let meteorologicalParameters = uni.getStorageSync('meteorologicalParameters');
		let dailyList = calibrationList.filter(item => item.correctType == '日常');
		//console.log("333333",dailyList);
		let passFalg = dailyList.every(function(item) { return item.isPass==1;});
		//console.log("444444",passFalg);
		let qxFalg = meteorologicalParameters.length !==0;
		if(!passFalg){
			uni.showToast({
				icon: 'none',
				title: "校准信息有未通过的数据！"
			})
		}
		if(!qxFalg){
			uni.showToast({
				icon: 'none',
				title: "请添加气象参数！"
			})
		}
		if(passFalg && qxFalg ){
			//uni.clearStorageSync("calibrationManagementList");
			//uni.clearStorageSync("meteorologicalParameters");
			uni.navigateTo({
				url: '/pages/testing/testingDetectionPointList?taskId='+ taskId.value
						});
			
		}
		//console.log("55555",qxFalg);
	}
</script>

<style scoped lang="scss">
	.task-result{
		width:100%;
		height:100rpx;
		background-color: #455bdf;
		display: flex;
		flex-direction: row;
		.result-item{
			width:300rpx;
			height:100%;
			//border-right: solid 1rpx #000;
			text-align: center;
			line-height:3;
			color:#ffffff;
		}
	}
	.schedule-circle{
		width:100%;
		height:650rpx;
		background-color: #aaffff;
		padding-top:35rpx;
			.progressBox {
				position: relative;
				width: 500rpx;
				height: 500rpx;
				margin: 0 auto;
				//margin-top: 20rpx;
			}
		
			.centerTxt {
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
		
				.num {
					font-size: 30rpx;
					font-family: Arial;
					font-weight: bold;
					color: #38393A;
				}
		
				.txt {
					font-size: 22rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #8A8B8B;
					margin-top: 10rpx;
				}
		
			}

	}
    .config-content{
		width:100%;
		height:285rpx;
		display: flex;
		flex-direction: row;
		padding-top:10rpx;
		padding-left:10rpx;
		padding-right:10rpx;
		padding-bottom: 10rpx;
		.detection-parameter{
			width:47%;
			background-color:#ff93ab;
			text-align: center;
			.detection-icon{
				height:120rpx;
			}
			.button-text-one{
				font-size: 24px;
				color:#948aff
			}
		}
		.meteorological-parameter{
			width:47%;
			background-color:#aaaaff ;
			margin-left: 20rpx;
			text-align: center;
			padding-top:120rpx;
			.meteorological-icon{
				height:120rpx;
			}
			.button-text-two{
				font-size: 24px;
				color: #ffaa00;
			}
		}
		
	}
	.start-button {
		position: fixed;
		bottom: 10rpx;
		left: 0;
		width: 100%;
		padding: 25rpx 82rpx;
		background: white;
		z-index: 2;
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		background: rgba(255, 255, 255, 0.6);
		uni-button {
			line-height: 100rpx !important;
			font-size: 30rpx;
		}
	}
</style>